<?php
require_once '../config/config.php';
require_once '../config/common.php';
//$user = checksession();
$conn = new mysqli(HOST, USER, PASSWORD, DATABASE);
if ($conn->connect_errno) {
    die('数据库连接失败' . $conn->connect_error);
}
$stmt = $conn->prepare('select * from media_list where type=?');
$stmt->bind_param('i', $_REQUEST['type']);
$stmt->execute();
$stmt->bind_result($id, $type, $content, $title, $time, $src);
?>
<!DOCTYPE html>

<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <p><a href="mediaadd.php?type=<?php echo $_REQUEST['type'] ?>">增加</a></p>
        <table border="1">
            <thead>
                <tr>
                    <th>id</th>
                    <th>type</th>
                    <th>content</th>
                    <th>title</th>
                    <th>time</th>
                    <th>img</th>
                    <th>operation</th><!--操作-->
                </tr>
            </thead>
            <tbody>
                <?php
                while ($stmt->fetch()) {
                    ?> 
                    <tr>
                        <td><?php echo $id; ?></td>
                        <td><?php echo $type; ?></td>
                        <td><?php echo $content; ?></td>
                        <td><?php echo $title; ?></td>
                        <td><?php echo date('y-m-d h:i:s', $time) ?></td> 
                        <td><?php echo $src; ?></td>
                        <td><a id="delete" href="mediaoperation.php?act=del&id=<?php echo $id; ?>&type=<?php echo $type; ?>&img=<?php echo $src; ?>">删除</a>
                            <a href="mediaupdate.php?id=<?php echo $id; ?>&type=<?php echo $type; ?>&img=<?php echo $src;?>">修改</a>
                        </td>
                    </tr>
                    <?php
                }
                ?>
            </tbody>
        </table>
        <script>
        $("#delete").click(function (e) {
    if (confirm("是否删除")) {
        return true;
    } else {
        e.preventDefault();//阻止浏览器的默认事件
    }
});
</script>
    </body>
</html>
